package com.huawo.qjs;

import android.os.Handler;

import com.huawo.qjs.callback.QjsZipCompletedListener;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class QjsZipTask implements Runnable {
    private Handler handler;
    private Executor executor;

    private QjsWatchface watchface;
    private QjsZipCompletedListener completedListener;

    public QjsZipTask(QjsWatchface watchface, Handler handler, QjsZipCompletedListener completedListener) {
        this.watchface = watchface;
        this.handler = handler;
        this.executor = Executors.newSingleThreadExecutor();
        this.completedListener = completedListener;
    }

    public void execute() {
        executor.execute(this);
    }

    @Override
    public void run() {
        watchface.make();
        // 在主线程中进行回调
        handler.postDelayed(() -> {
            // 处理任务完成的回调，例如更新UI
            this.completedListener.onCompleted();
        },2500);
    }
}
